<!--
 @description 经销商档案变更-预览
 @fileName index.vue
 @author zengqiongying
 @created 2023/04/21 10:42:06
-->
<template>
  <div>
    <DetailInfo :id="id" />
  </div>
</template>

<script lang="ts">
  import { ref, getCurrentInstance } from 'vue'
  import { useRoute, onBeforeRouteLeave } from 'vue-router'
  import { useStore } from 'vuex'
  import DetailInfo from './DetailInfo.vue'
  export default {
    name: 'DealerArchiveChangePreview',
    components: { DetailInfo },
    setup() {
      const instance = getCurrentInstance()
      const $store = useStore()
      const $route = useRoute()
      const id = ref(`${$route.query.id || ''}`)

      onBeforeRouteLeave((to, from) => {
        const instanceName = instance?.type?.name
        const toName: any = to.name
        if (
          [
            'DealerArchiveChangeDetailShopContacts',
            'DealerArchiveChangeDetailContacts',
            'DealerArchiveChangeDetailAddress'
          ].includes(toName)
        ) {
          $store.commit('routerKeep/resetCache', instanceName)
        } else {
          $store.commit('routerKeep/removeCache', instanceName)
        }
      })
      return {
        id
      }
    }
  }
</script>
<style lang="less" scoped></style>
